package com.greate.community.service.impl;

import com.greate.community.entity.Post;
import com.greate.community.mapper.PostMapper;
import com.greate.community.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PostServiceImpl implements PostService {

    @Autowired
    private PostMapper postMapper;

    @Override
    public List<Post> findAllPosts() {
        return postMapper.selectAllPosts();
    }

    @Override
    public Post findPostById(int id) {
        return postMapper.selectPostById(id);
    }

    @Override
    public List<Post> findPostsByUserId(int userId) {
        return postMapper.selectPostsByUserId(userId);
    }

    @Override
    public int addPost(Post post) {
        return postMapper.insertPost(post);
    }

    @Override
    public int updatePost(Post post) {
        return postMapper.updatePost(post);
    }

    @Override
    public int deletePost(int id) {
        return postMapper.deletePost(id);
    }

    @Override
    public int updatePostStatus(int id, int status) {
        return postMapper.updatePostStatus(id, status);
    }

    @Override
    public int updatePostType(int id, int type) {
        return postMapper.updatePostType(id, type);
    }

    @Override
    public int updateCommentCount(int id, int commentCount) {
        return postMapper.updateCommentCount(id, commentCount);
    }

    @Override
    public int updateScore(int id, double score) {
        return postMapper.updateScore(id, score);
    }
} 